Use the REST pagination signal for tag lists#25804
Open
jkmassel wants to merge 8 commits into
Open
Conversation
Self-hosted taxonomy went through XML-RPC term methods, which some hosts block at the WAF, breaking tags and categories on new posts (#25758). Prefer the core REST API (wp/v2) whenever the site has application-password access, keeping XML-RPC only as a fallback for legacy sites without it.
The two convenience initializers were ambiguous about when to use each. Introduce tags(for:) and taxonomy(_:client:) so call sites read by intent, and drop the unused blog parameter that was threaded through the custom taxonomy path.
TagsViewModel inferred `hasMore` from `count == 100`, so a tag list whose size is an exact multiple of the page size requested a page past the last one. On the wp/v2 path that returns 400 (rest_term_invalid_page_number), surfacing a stuck pagination error where the offset-based path stopped cleanly. Return `hasMore` from `getTags` instead: AnyTermService derives it from the response's `nextPageParams`; TagsService keeps the count check that is safe for its offset-based remotes.
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 33239 | |
| Version | PR #25804 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | f25653d | |
| Installation URL | 1daa6jonabf38 |
Contributor
This error code does not seem to exist. Here are curl test results: I also can't reproduce the issue in the app. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Suggestion for #25767 (base:
bugfix/selfhosted-taxonomy-rest) — fixes a tag-list pagination bug.Summary
TagsViewModelinferredhasMorefromremoteTags.count == 100, so a tag list whose size is an exact multiple of the page size (100, 200, …) requested a page past the last one.AnyTermService(wp/v2, page-number paging), that over-page request returns400 rest_term_invalid_page_number, surfacing a stuck pagination error footer. The prior offset-based path returned an empty page and stopped cleanly.Root Cause
AnyTermService.getTagsdiscarded the response'snextPageParams— wp/v2's authoritative "is there another page" signal — and returned onlyresponse.data, forcingTagsViewModelto guesshasMorefrom the item count. That guess is wrong exactly when the last page is full.Fix
TaxonomyServiceProtocol.getTagsnow returns(terms:hasMore:):AnyTermServicederiveshasMorefromresponse.nextPageParams != nil(the wp/v2 signal).TagsServicekeeps thecount == pageSizecheck, which is safe for its offset-based XML-RPC / WP.com remotes — an over-offset request returns an empty page, not a 400.TagsViewModeluses the returnedhasMoreinstead ofcount == 100.Contained to the two
getTagsimplementations and their single caller; no other conformers.Test Plan